3.1.73 \(\int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx\) [73]

Optimal. Leaf size=99 \[ \frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {\left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right ) f} \]

[Out]

(A*c+B*d-C*c)*x/(c^2+d^2)-(B*c-(A-C)*d)*ln(cos(f*x+e))/(c^2+d^2)/f+(A*d^2-B*c*d+C*c^2)*ln(c+d*tan(f*x+e))/d/(c
^2+d^2)/f

________________________________________________________________________________________

Rubi [A]
time = 0.07, antiderivative size = 99, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 33, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.121, Rules used = {3707, 3698, 31, 3556} \begin {gather*} \frac {\left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}-\frac {(B c-d (A-C)) \log (\cos (e+f x))}{f \left (c^2+d^2\right )}+\frac {x (A c+B d-c C)}{c^2+d^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((A*c - c*C + B*d)*x)/(c^2 + d^2) - ((B*c - (A - C)*d)*Log[Cos[e + f*x]])/((c^2 + d^2)*f) + ((c^2*C - B*c*d +
A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)*f)

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3698

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
A/(b*f), Subst[Int[(a + x)^m, x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]

Rule 3707

Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/((a_.) + (b_.)*tan[(e_.) + (f_.)*
(x_)]), x_Symbol] :> Simp[(a*A + b*B - a*C)*(x/(a^2 + b^2)), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2), I
nt[(1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Dist[(A*b - a*B - b*C)/(a^2 + b^2), Int[Tan[e + f*x], x
], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a
*B - b*C, 0]

Rubi steps

\begin {align*} \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(-B c+A d-C d) \int \tan (e+f x) \, dx}{c^2+d^2}+\frac {\left (c^2 C-B c d+A d^2\right ) \int \frac {1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{c^2+d^2}\\ &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {\left (c^2 C-B c d+A d^2\right ) \text {Subst}\left (\int \frac {1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d \left (c^2+d^2\right ) f}\\ &=\frac {(A c-c C+B d) x}{c^2+d^2}-\frac {(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {\left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right ) f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C] Result contains complex when optimal does not.
time = 0.14, size = 117, normalized size = 1.18 \begin {gather*} \frac {\frac {(-i A+B+i C) \log (i-\tan (e+f x))}{c+i d}+\frac {(i A+B-i C) \log (i+\tan (e+f x))}{c-i d}+\frac {2 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right )}}{2 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((((-I)*A + B + I*C)*Log[I - Tan[e + f*x]])/(c + I*d) + ((I*A + B - I*C)*Log[I + Tan[e + f*x]])/(c - I*d) + (2
*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)))/(2*f)

________________________________________________________________________________________

Maple [A]
time = 0.19, size = 100, normalized size = 1.01

method result size
derivativedivides \(\frac {\frac {\frac {\left (-A d +B c +C d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A c +B d -c C \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}+\frac {\left (A \,d^{2}-B c d +c^{2} C \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d}}{f}\) \(100\)
default \(\frac {\frac {\frac {\left (-A d +B c +C d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (A c +B d -c C \right ) \arctan \left (\tan \left (f x +e \right )\right )}{c^{2}+d^{2}}+\frac {\left (A \,d^{2}-B c d +c^{2} C \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right ) d}}{f}\) \(100\)
norman \(\frac {\left (A c +B d -c C \right ) x}{c^{2}+d^{2}}+\frac {\left (A \,d^{2}-B c d +c^{2} C \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{d \left (c^{2}+d^{2}\right ) f}-\frac {\left (A d -B c -C d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 f \left (c^{2}+d^{2}\right )}\) \(104\)
risch \(\frac {i x B}{i d -c}-\frac {x A}{i d -c}+\frac {x C}{i d -c}-\frac {2 i d A x}{c^{2}+d^{2}}-\frac {2 i d A e}{\left (c^{2}+d^{2}\right ) f}+\frac {2 i B c x}{c^{2}+d^{2}}+\frac {2 i B c e}{\left (c^{2}+d^{2}\right ) f}-\frac {2 i c^{2} C x}{\left (c^{2}+d^{2}\right ) d}-\frac {2 i c^{2} C e}{\left (c^{2}+d^{2}\right ) d f}+\frac {2 i C x}{d}+\frac {2 i C e}{d f}+\frac {d \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) A}{\left (c^{2}+d^{2}\right ) f}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) B c}{\left (c^{2}+d^{2}\right ) f}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) c^{2} C}{\left (c^{2}+d^{2}\right ) d f}-\frac {C \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{d f}\) \(331\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

1/f*(1/(c^2+d^2)*(1/2*(-A*d+B*c+C*d)*ln(1+tan(f*x+e)^2)+(A*c+B*d-C*c)*arctan(tan(f*x+e)))+(A*d^2-B*c*d+C*c^2)/
(c^2+d^2)/d*ln(c+d*tan(f*x+e)))

________________________________________________________________________________________

Maxima [A]
time = 0.59, size = 109, normalized size = 1.10 \begin {gather*} \frac {\frac {2 \, {\left ({\left (A - C\right )} c + B d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {2 \, {\left (C c^{2} - B c d + A d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d + d^{3}} + \frac {{\left (B c - {\left (A - C\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}}}{2 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*((A - C)*c + B*d)*(f*x + e)/(c^2 + d^2) + 2*(C*c^2 - B*c*d + A*d^2)*log(d*tan(f*x + e) + c)/(c^2*d + d^
3) + (B*c - (A - C)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2))/f

________________________________________________________________________________________

Fricas [A]
time = 4.74, size = 122, normalized size = 1.23 \begin {gather*} \frac {2 \, {\left ({\left (A - C\right )} c d + B d^{2}\right )} f x + {\left (C c^{2} - B c d + A d^{2}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (C c^{2} + C d^{2}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \, {\left (c^{2} d + d^{3}\right )} f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*((A - C)*c*d + B*d^2)*f*x + (C*c^2 - B*c*d + A*d^2)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) + c^2)
/(tan(f*x + e)^2 + 1)) - (C*c^2 + C*d^2)*log(1/(tan(f*x + e)^2 + 1)))/((c^2*d + d^3)*f)

________________________________________________________________________________________

Sympy [C] Result contains complex when optimal does not.
time = 0.61, size = 966, normalized size = 9.76 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right )}{\tan {\left (e \right )}} & \text {for}\: c = 0 \wedge d = 0 \wedge f = 0 \\\frac {i A f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {A f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {i A}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {B f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {i B f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {B}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {i C f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {C f x}{2 d f \tan {\left (e + f x \right )} - 2 i d f} + \frac {C \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {i C \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 d f \tan {\left (e + f x \right )} - 2 i d f} - \frac {i C}{2 d f \tan {\left (e + f x \right )} - 2 i d f} & \text {for}\: c = - i d \\- \frac {i A f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {A f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {i A}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {B f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {i B f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {B}{2 d f \tan {\left (e + f x \right )} + 2 i d f} - \frac {i C f x \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {C f x}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {C \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {i C \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 d f \tan {\left (e + f x \right )} + 2 i d f} + \frac {i C}{2 d f \tan {\left (e + f x \right )} + 2 i d f} & \text {for}\: c = i d \\\frac {A x + \frac {B \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 f} - C x + \frac {C \tan {\left (e + f x \right )}}{f}}{c} & \text {for}\: d = 0 \\\frac {x \left (A + B \tan {\left (e \right )} + C \tan ^{2}{\left (e \right )}\right )}{c + d \tan {\left (e \right )}} & \text {for}\: f = 0 \\\frac {2 A c d f x}{2 c^{2} d f + 2 d^{3} f} + \frac {2 A d^{2} \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {A d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {2 B c d \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} + \frac {B c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} + \frac {2 B d^{2} f x}{2 c^{2} d f + 2 d^{3} f} + \frac {2 C c^{2} \log {\left (\frac {c}{d} + \tan {\left (e + f x \right )} \right )}}{2 c^{2} d f + 2 d^{3} f} - \frac {2 C c d f x}{2 c^{2} d f + 2 d^{3} f} + \frac {C d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} d f + 2 d^{3} f} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e)),x)

[Out]

Piecewise((zoo*x*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), (I*A*f*x*tan(e + f*x)/(
2*d*f*tan(e + f*x) - 2*I*d*f) + A*f*x/(2*d*f*tan(e + f*x) - 2*I*d*f) + I*A/(2*d*f*tan(e + f*x) - 2*I*d*f) + B*
f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) - I*B*f*x/(2*d*f*tan(e + f*x) - 2*I*d*f) - B/(2*d*f*tan(e + f*
x) - 2*I*d*f) + I*C*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) + C*f*x/(2*d*f*tan(e + f*x) - 2*I*d*f) + C
*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(2*d*f*tan(e + f*x) - 2*I*d*f) - I*C*log(tan(e + f*x)**2 + 1)/(2*d*f*ta
n(e + f*x) - 2*I*d*f) - I*C/(2*d*f*tan(e + f*x) - 2*I*d*f), Eq(c, -I*d)), (-I*A*f*x*tan(e + f*x)/(2*d*f*tan(e
+ f*x) + 2*I*d*f) + A*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) - I*A/(2*d*f*tan(e + f*x) + 2*I*d*f) + B*f*x*tan(e +
f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + I*B*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) - B/(2*d*f*tan(e + f*x) + 2*I*d*f
) - I*C*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + C*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) + C*log(tan(e +
 f*x)**2 + 1)*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*log(tan(e + f*x)**2 + 1)/(2*d*f*tan(e + f*x) +
 2*I*d*f) + I*C/(2*d*f*tan(e + f*x) + 2*I*d*f), Eq(c, I*d)), ((A*x + B*log(tan(e + f*x)**2 + 1)/(2*f) - C*x +
C*tan(e + f*x)/f)/c, Eq(d, 0)), (x*(A + B*tan(e) + C*tan(e)**2)/(c + d*tan(e)), Eq(f, 0)), (2*A*c*d*f*x/(2*c**
2*d*f + 2*d**3*f) + 2*A*d**2*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) - A*d**2*log(tan(e + f*x)**2 + 1)
/(2*c**2*d*f + 2*d**3*f) - 2*B*c*d*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) + B*c*d*log(tan(e + f*x)**2
 + 1)/(2*c**2*d*f + 2*d**3*f) + 2*B*d**2*f*x/(2*c**2*d*f + 2*d**3*f) + 2*C*c**2*log(c/d + tan(e + f*x))/(2*c**
2*d*f + 2*d**3*f) - 2*C*c*d*f*x/(2*c**2*d*f + 2*d**3*f) + C*d**2*log(tan(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3
*f), True))

________________________________________________________________________________________

Giac [A]
time = 0.64, size = 109, normalized size = 1.10 \begin {gather*} \frac {\frac {2 \, {\left (A c - C c + B d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {{\left (B c - A d + C d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, {\left (C c^{2} - B c d + A d^{2}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d + d^{3}}}{2 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(A*c - C*c + B*d)*(f*x + e)/(c^2 + d^2) + (B*c - A*d + C*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + 2*(C*
c^2 - B*c*d + A*d^2)*log(abs(d*tan(f*x + e) + c))/(c^2*d + d^3))/f

________________________________________________________________________________________

Mupad [B]
time = 9.90, size = 109, normalized size = 1.10 \begin {gather*} \frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (C-A+B\,1{}\mathrm {i}\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B-A\,1{}\mathrm {i}+C\,1{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (C\,c^2-B\,c\,d+A\,d^2\right )}{d\,f\,\left (c^2+d^2\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A + B*tan(e + f*x) + C*tan(e + f*x)^2)/(c + d*tan(e + f*x)),x)

[Out]

(log(tan(e + f*x) + 1i)*(B*1i - A + C))/(2*f*(c*1i + d)) + (log(tan(e + f*x) - 1i)*(B - A*1i + C*1i))/(2*f*(c
+ d*1i)) + (log(c + d*tan(e + f*x))*(A*d^2 + C*c^2 - B*c*d))/(d*f*(c^2 + d^2))

________________________________________________________________________________________